/**
 * @param {number[]} obstacles
 * @return {number}
 */
 var minSideJumps = function(obstacles) {
    if(!obstacles.includes(2))
        return 0
    const n = obstacles.length
    let pos = [0,0,0]
    for(let i = 0; i<n-1; i++){
        if(obstacles[i] > 0)
            pos[obstacles[i]-1] = i
    }
    let min = Math.min(...pos)
    let c = pos.indexOf(min) + 1
    let ans = 0, pre = -1
    for(let i = 0; i<min+1; i++){
        if(obstacles[i] > 0 && obstacles[i] !== pre){
            ans += 2
            pre = obstacles[i]
        }
            
    }
    return ans
};